jsx3.lang.Class.defineClass("ux.core.util.effect.Effect", 
  null, 
  null,
  function(fade) {
    
    fade.prototype.init = function(TimeStep, AlphaStep) {
      //alert(jsx3.lang.ClassLoader.getType());  
      this.TimeStep = TimeStep?TimeStep:20;
      this.isIe = (window.ActiveXObject) ? true : false;
      //this.isIe = jsx3.lang.ClassLoader.getType
      this.AlphaStep = AlphaStep?AlphaStep:10;
      this.CurrObj = null;
      this.opacity = 0;
      this.timeout = null;
    }
    
    fade.prototype.do_fadeIn = function(obj,callback, callObj, TimeStep, AlphaStep) {
      if(!obj)return;
      this.init(TimeStep, AlphaStep);
      this.CurrObj = obj;
      this.CurrObj.style.zoom = 1;
      this.opacity = 0;
      this.fadein(callback, callObj);
    }
  
    fade.prototype.fadein = function(callback, callObj) {
	  jsx3.log('FadeEffect#fadein callback : ' + callback);
      var me = this;
      this.setOpacity(this.CurrObj, this.opacity);
      this.opacity += this.AlphaStep;
      if (this.opacity <= 100) {
        this.timeout = window.setTimeout(function() {me.fadein(callback, callObj); }, this.TimeStep);
      }else{
        this.setOpacity(this.CurrObj, 100);
        clearTimeout(this.timeout);
        if(callback) {
			if(typeof(callback) == 'function')
				callback.apply(callObj,[]);
			else if(callback instanceof Array && callback.length > 0){
				jsx3.log('FadeEffect#fadein callbacks : ' + callback.length);
				for(var i=0;i<callback.length;i++)
					try{callback[i].apply(callObj,[]);}catch(e){}
			}
		}
      }
    }
    
    fade.prototype.do_fadeOut = function(obj,callback, callObj, TimeStep, AlphaStep) {
      if(!obj)return;
      this.init(TimeStep, AlphaStep);
      this.CurrObj =obj;
      this.CurrObj.style.zoom = 1;
      this.opacity = 100;
      this.fadeout(callback, callObj);
    }
    
//    fade.prototype.fade_out = function(obj){
//      obj.setOpacity(obj.CurrObj, obj.opacity);
//      obj.opacity -= obj.AlphaStep;
//      if (obj.opacity >= 0) {
//        //this.timeout = this.fade_out()
//        //window.setTimeout(function() {alert(me.fade_out()); }, 2000);
//        window.setTimeout(function() { ope(obj) }, 200);
//      }else{
//        //clearOpacity();
//        //clearTimeout(this.timeout);
//        alert('end');
//      }
//    }

    fade.prototype.fadeout = function(callback, callObj){
	  jsx3.log('FadeEffect#fadeout callback : ' + callback);
      var me = this;
      this.setOpacity(this.CurrObj, this.opacity);
      this.opacity -= this.AlphaStep;
      if (this.opacity >= 0) {
        this.timeout = window.setTimeout(function() {me.fadeout(callback, callObj); }, this.TimeStep);
      }else{
        this.setOpacity(this.CurrObj, 0);
        clearTimeout(this.timeout);
        if(callback) {
			if(typeof(callback) == 'function')
				callback.apply(callObj,[]);
			else if(callback instanceof Array && callback.length > 0){
				jsx3.log('FadeEffect#fadeout callbacks : ' + callback.length);
				for(var i=0;i<callback.length;i++)
					try{callback[i].apply(callObj,[]);}catch(e){}
			}
		}
      }
    }
    
    fade.prototype.setOpacity = function(obj,value){
      //FILTER: alpha(opacity=0)
      if(this.isIe)obj.style.filter = 'alpha(opacity='+ value +')';
      else obj.style.opacity = value/100;
    }
    
  //  fade.prototype.clearOpacity = function(){ 
  //    if (isIe) {
  //      if (typeof CurrObj.style.filter == 'string' && (/alpha/i).test(CurrObj.style.filter)) {
  //        CurrObj.style.filter = "";
  //      }
  //    }
  //    else {
  //      CurrObj.style.opacity = "";
  //      CurrObj.style["-moz-opacity"] = "";
  //      CurrObj.style["-khtml-opacity"] = "";
  //    }
  //  }
    
  //  fade.prototype.setOpacity = function(opacity, animate){
  //    /*
  //    if(!animate || !A){
  //        var s = CurrObj.style;
  //        if(isIe){
  //            s.zoom = 1;
  //            s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi,"") +
  //                       (opacity == 1 ? "" : " alpha(opacity=" + opacity * 100 + ")");
  //        }else{
  //            s.opacity = opacity;
  //        }
  //    }else{
  //        //this.anim({opacity: {to: opacity}}, this.preanim(arguments, 1), null, .35, 'easeIn');
  //    }
  //   */
  //  }
  }
 );
